<?php
/**
 * Created by PhpStorm.
 * User: Guangpeng Chen
 * Date: 15-6-10
 * Time: 上午9:27
 */

include 'PftShow.class.php';
//include '../common/Db.class.php';
//$dbConf = include '../common/db.conf.php';
//$db = \PFT\Db::Connect();
$ps = new \PFT\Show\PftShow();

$data_arr = array(
    array('id'=>1,'begin_date'=>'2015-05-01','end_date'=>'2015-05-04','weeks'=>'0|1|3'),
    array('id'=>2,'begin_date'=>'2015-05-06','end_date'=>'2015-05-14','weeks'=>'4|5'),
    array('id'=>3,'begin_date'=>'2015-05-15','end_date'=>'2015-05-18','weeks'=>'5|6'),
    array('id'=>4,'begin_date'=>'2015-06-01','end_date'=>'2015-06-04','weeks'=>'1|3'),
);
function isMixDate($bt1, $et1, $bt2, $et2)
{
    return $bt1 <= $et2 && $et1 >= $bt2;
}
$weeks_arr = array(1,3,4);
foreach ($data_arr as $date) {
    $chk = isMixDate($date['begin_date'],$date['end_date'],'2015-05-08', '2015-05-10');
    var_dump($chk);
    echo str_repeat('-', 100),PHP_EOL;
    if ($chk===true) {
        $weeks_arr_chk = explode('|', $date['weeks']);
        $chk_2 = array_intersect($weeks_arr, $weeks_arr_chk);
        if (count($chk_2)) {
            var_dump($chk_2);
            echo $date['begin_date'],'--',$date['end_date'],'--',$date['weeks'];
            echo PHP_EOL;
        }
    }
}
//$ret = $ps->CheckDate($data_arr,'2015-05-08', '2015-05-10');
//var_dump($ret);
$weeks = 'a';

$weeks_2 = array_filter(explode('|', $weeks), function($val){
    return is_numeric($val) && $val<8;
});
var_dump($weeks_2);